1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module pango.PgContext; 26 27 private import glib.ConstructionException; 28 private import glib.ListG; 29 private import glib.Str; 30 private import gobject.ObjectG; 31 private import pango.PgAttributeIterator; 32 private import pango.PgAttributeList; 33 private import pango.PgFont; 34 private import pango.PgFontDescription; 35 private import pango.PgFontFamily; 36 private import pango.PgFontMap; 37 private import pango.PgFontMetrics; 38 private import pango.PgFontset; 39 private import pango.PgGlyphString; 40 private import pango.PgItem; 41 private import pango.PgLanguage; 42 private import pango.PgMatrix; 43 private import pango.c.functions; 44 public import pango.c.types; 45 46 47 /** 48 * A `PangoContext` stores global information used to control the 49 * itemization process. 50 * 51 * The information stored by `PangoContext` includes the fontmap used 52 * to look up fonts, and default values such as the default language, 53 * default gravity, or default font. 54 * 55 * To obtain a `PangoContext`, use [method@Pango.FontMap.create_context]. 56 */ 57 public class PgContext : ObjectG 58 { 59 /** the main Gtk struct */ 60 protected PangoContext* pangoContext; 61 62 /** Get the main Gtk struct */ 63 public PangoContext* getPgContextStruct(bool transferOwnership = false) 64 { 65 if (transferOwnership) 66 ownedRef = false; 67 return pangoContext; 68 } 69 70 /** the main Gtk struct as a void* */ 71 protected override void* getStruct() 72 { 73 return cast(void*)pangoContext; 74 } 75 76 /** 77 * Sets our main struct and passes it to the parent class. 78 */ 79 public this (PangoContext* pangoContext, bool ownedRef = false) 80 { 81 this.pangoContext = pangoContext; 82 super(cast(GObject*)pangoContext, ownedRef); 83 } 84 85 86 /** */ 87 public static GType getType() 88 { 89 return pango_context_get_type(); 90 } 91 92 /** 93 * Creates a new `PangoContext` initialized to default values. 94 * 95 * This function is not particularly useful as it should always 96 * be followed by a [method@Pango.Context.set_font_map] call, and the 97 * function [method@Pango.FontMap.create_context] does these two steps 98 * together and hence users are recommended to use that. 99 * 100 * If you are using Pango as part of a higher-level system, 101 * that system may have it's own way of create a `PangoContext`. 102 * For instance, the GTK toolkit has, among others, 103 * `gtk_widget_get_pango_context()`. Use those instead. 104 * 105 * Returns: the newly allocated `PangoContext`, which should 106 * be freed with g_object_unref(). 107 * 108 * Throws: ConstructionException GTK+ fails to create the object. 109 */ 110 public this() 111 { 112 auto __p = pango_context_new(); 113 114 if(__p is null) 115 { 116 throw new ConstructionException("null returned by new"); 117 } 118 119 this(cast(PangoContext*) __p, true); 120 } 121 122 /** 123 * Forces a change in the context, which will cause any `PangoLayout` 124 * using this context to re-layout. 125 * 126 * This function is only useful when implementing a new backend 127 * for Pango, something applications won't do. Backends should 128 * call this function if they have attached extra data to the context 129 * and such data is changed. 130 * 131 * Since: 1.32.4 132 */ 133 public void changed() 134 { 135 pango_context_changed(pangoContext); 136 } 137 138 /** 139 * Retrieves the base direction for the context. 140 * 141 * See [method@Pango.Context.set_base_dir]. 142 * 143 * Returns: the base direction for the context. 144 */ 145 public PangoDirection getBaseDir() 146 { 147 return pango_context_get_base_dir(pangoContext); 148 } 149 150 /** 151 * Retrieves the base gravity for the context. 152 * 153 * See [method@Pango.Context.set_base_gravity]. 154 * 155 * Returns: the base gravity for the context. 156 * 157 * Since: 1.16 158 */ 159 public PangoGravity getBaseGravity() 160 { 161 return pango_context_get_base_gravity(pangoContext); 162 } 163 164 /** 165 * Retrieve the default font description for the context. 166 * 167 * Returns: a pointer to the context's default font 168 * description. This value must not be modified or freed. 169 */ 170 public PgFontDescription getFontDescription() 171 { 172 auto __p = pango_context_get_font_description(pangoContext); 173 174 if(__p is null) 175 { 176 return null; 177 } 178 179 return ObjectG.getDObject!(PgFontDescription)(cast(PangoFontDescription*) __p); 180 } 181 182 /** 183 * Gets the `PangoFontMap` used to look up fonts for this context. 184 * 185 * Returns: the font map for the `PangoContext`. 186 * This value is owned by Pango and should not be unreferenced. 187 * 188 * Since: 1.6 189 */ 190 public PgFontMap getFontMap() 191 { 192 auto __p = pango_context_get_font_map(pangoContext); 193 194 if(__p is null) 195 { 196 return null; 197 } 198 199 return ObjectG.getDObject!(PgFontMap)(cast(PangoFontMap*) __p); 200 } 201 202 /** 203 * Retrieves the gravity for the context. 204 * 205 * This is similar to [method@Pango.Context.get_base_gravity], 206 * except for when the base gravity is %PANGO_GRAVITY_AUTO for 207 * which [func@Pango.Gravity.get_for_matrix] is used to return the 208 * gravity from the current context matrix. 209 * 210 * Returns: the resolved gravity for the context. 211 * 212 * Since: 1.16 213 */ 214 public PangoGravity getGravity() 215 { 216 return pango_context_get_gravity(pangoContext); 217 } 218 219 /** 220 * Retrieves the gravity hint for the context. 221 * 222 * See [method@Pango.Context.set_gravity_hint] for details. 223 * 224 * Returns: the gravity hint for the context. 225 * 226 * Since: 1.16 227 */ 228 public PangoGravityHint getGravityHint() 229 { 230 return pango_context_get_gravity_hint(pangoContext); 231 } 232 233 /** 234 * Retrieves the global language tag for the context. 235 * 236 * Returns: the global language tag. 237 */ 238 public PgLanguage getLanguage() 239 { 240 auto __p = pango_context_get_language(pangoContext); 241 242 if(__p is null) 243 { 244 return null; 245 } 246 247 return ObjectG.getDObject!(PgLanguage)(cast(PangoLanguage*) __p, true); 248 } 249 250 /** 251 * Gets the transformation matrix that will be applied when 252 * rendering with this context. 253 * 254 * See [method@Pango.Context.set_matrix]. 255 * 256 * Returns: the matrix, or %NULL if no matrix has 257 * been set (which is the same as the identity matrix). The returned 258 * matrix is owned by Pango and must not be modified or freed. 259 * 260 * Since: 1.6 261 */ 262 public PgMatrix getMatrix() 263 { 264 auto __p = pango_context_get_matrix(pangoContext); 265 266 if(__p is null) 267 { 268 return null; 269 } 270 271 return ObjectG.getDObject!(PgMatrix)(cast(PangoMatrix*) __p); 272 } 273 274 /** 275 * Get overall metric information for a particular font description. 276 * 277 * Since the metrics may be substantially different for different scripts, 278 * a language tag can be provided to indicate that the metrics should be 279 * retrieved that correspond to the script(s) used by that language. 280 * 281 * The `PangoFontDescription` is interpreted in the same way as by [func@itemize], 282 * and the family name may be a comma separated list of names. If characters 283 * from multiple of these families would be used to render the string, then 284 * the returned fonts would be a composite of the metrics for the fonts loaded 285 * for the individual families. 286 * 287 * Params: 288 * desc = a `PangoFontDescription` structure. %NULL means that the 289 * font description from the context will be used. 290 * language = language tag used to determine which script to get 291 * the metrics for. %NULL means that the language tag from the context 292 * will be used. If no language tag is set on the context, metrics 293 * for the default language (as determined by [func@Pango.Language.get_default] 294 * will be returned. 295 * 296 * Returns: a `PangoFontMetrics` object. The caller must call 297 * [method@Pango.FontMetrics.unref] when finished using the object. 298 */ 299 public PgFontMetrics getMetrics(PgFontDescription desc, PgLanguage language) 300 { 301 auto __p = pango_context_get_metrics(pangoContext, (desc is null) ? null : desc.getPgFontDescriptionStruct(), (language is null) ? null : language.getPgLanguageStruct()); 302 303 if(__p is null) 304 { 305 return null; 306 } 307 308 return ObjectG.getDObject!(PgFontMetrics)(cast(PangoFontMetrics*) __p, true); 309 } 310 311 /** 312 * Returns whether font rendering with this context should 313 * round glyph positions and widths. 314 * 315 * Since: 1.44 316 */ 317 public bool getRoundGlyphPositions() 318 { 319 return pango_context_get_round_glyph_positions(pangoContext) != 0; 320 } 321 322 /** 323 * Returns the current serial number of @context. 324 * 325 * The serial number is initialized to an small number larger than zero 326 * when a new context is created and is increased whenever the context 327 * is changed using any of the setter functions, or the `PangoFontMap` it 328 * uses to find fonts has changed. The serial may wrap, but will never 329 * have the value 0. Since it can wrap, never compare it with "less than", 330 * always use "not equals". 331 * 332 * This can be used to automatically detect changes to a `PangoContext`, 333 * and is only useful when implementing objects that need update when their 334 * `PangoContext` changes, like `PangoLayout`. 335 * 336 * Returns: The current serial number of @context. 337 * 338 * Since: 1.32.4 339 */ 340 public uint getSerial() 341 { 342 return pango_context_get_serial(pangoContext); 343 } 344 345 /** 346 * List all families for a context. 347 * 348 * Params: 349 * families = location 350 * to store a pointer to an array of `PangoFontFamily`. This array should 351 * be freed with g_free(). 352 */ 353 public void listFamilies(out PgFontFamily[] families) 354 { 355 PangoFontFamily** outfamilies = null; 356 int nFamilies; 357 358 pango_context_list_families(pangoContext, &outfamilies, &nFamilies); 359 360 families = new PgFontFamily[nFamilies]; 361 for(size_t i = 0; i < nFamilies; i++) 362 { 363 families[i] = ObjectG.getDObject!(PgFontFamily)(cast(PangoFontFamily*) outfamilies[i]); 364 } 365 } 366 367 /** 368 * Loads the font in one of the fontmaps in the context 369 * that is the closest match for @desc. 370 * 371 * Params: 372 * desc = a `PangoFontDescription` describing the font to load 373 * 374 * Returns: the newly allocated `PangoFont` 375 * that was loaded, or %NULL if no font matched. 376 */ 377 public PgFont loadFont(PgFontDescription desc) 378 { 379 auto __p = pango_context_load_font(pangoContext, (desc is null) ? null : desc.getPgFontDescriptionStruct()); 380 381 if(__p is null) 382 { 383 return null; 384 } 385 386 return ObjectG.getDObject!(PgFont)(cast(PangoFont*) __p, true); 387 } 388 389 /** 390 * Load a set of fonts in the context that can be used to render 391 * a font matching @desc. 392 * 393 * Params: 394 * desc = a `PangoFontDescription` describing the fonts to load 395 * language = a `PangoLanguage` the fonts will be used for 396 * 397 * Returns: the newly allocated 398 * `PangoFontset` loaded, or %NULL if no font matched. 399 */ 400 public PgFontset loadFontset(PgFontDescription desc, PgLanguage language) 401 { 402 auto __p = pango_context_load_fontset(pangoContext, (desc is null) ? null : desc.getPgFontDescriptionStruct(), (language is null) ? null : language.getPgLanguageStruct()); 403 404 if(__p is null) 405 { 406 return null; 407 } 408 409 return ObjectG.getDObject!(PgFontset)(cast(PangoFontset*) __p, true); 410 } 411 412 /** 413 * Sets the base direction for the context. 414 * 415 * The base direction is used in applying the Unicode bidirectional 416 * algorithm; if the @direction is %PANGO_DIRECTION_LTR or 417 * %PANGO_DIRECTION_RTL, then the value will be used as the paragraph 418 * direction in the Unicode bidirectional algorithm. A value of 419 * %PANGO_DIRECTION_WEAK_LTR or %PANGO_DIRECTION_WEAK_RTL is used only 420 * for paragraphs that do not contain any strong characters themselves. 421 * 422 * Params: 423 * direction = the new base direction 424 */ 425 public void setBaseDir(PangoDirection direction) 426 { 427 pango_context_set_base_dir(pangoContext, direction); 428 } 429 430 /** 431 * Sets the base gravity for the context. 432 * 433 * The base gravity is used in laying vertical text out. 434 * 435 * Params: 436 * gravity = the new base gravity 437 * 438 * Since: 1.16 439 */ 440 public void setBaseGravity(PangoGravity gravity) 441 { 442 pango_context_set_base_gravity(pangoContext, gravity); 443 } 444 445 /** 446 * Set the default font description for the context 447 * 448 * Params: 449 * desc = the new pango font description 450 */ 451 public void setFontDescription(PgFontDescription desc) 452 { 453 pango_context_set_font_description(pangoContext, (desc is null) ? null : desc.getPgFontDescriptionStruct()); 454 } 455 456 /** 457 * Sets the font map to be searched when fonts are looked-up 458 * in this context. 459 * 460 * This is only for internal use by Pango backends, a `PangoContext` 461 * obtained via one of the recommended methods should already have a 462 * suitable font map. 463 * 464 * Params: 465 * fontMap = the `PangoFontMap` to set. 466 */ 467 public void setFontMap(PgFontMap fontMap) 468 { 469 pango_context_set_font_map(pangoContext, (fontMap is null) ? null : fontMap.getPgFontMapStruct()); 470 } 471 472 /** 473 * Sets the gravity hint for the context. 474 * 475 * The gravity hint is used in laying vertical text out, and 476 * is only relevant if gravity of the context as returned by 477 * [method@Pango.Context.get_gravity] is set to %PANGO_GRAVITY_EAST 478 * or %PANGO_GRAVITY_WEST. 479 * 480 * Params: 481 * hint = the new gravity hint 482 * 483 * Since: 1.16 484 */ 485 public void setGravityHint(PangoGravityHint hint) 486 { 487 pango_context_set_gravity_hint(pangoContext, hint); 488 } 489 490 /** 491 * Sets the global language tag for the context. 492 * 493 * The default language for the locale of the running process 494 * can be found using [func@Pango.Language.get_default]. 495 * 496 * Params: 497 * language = the new language tag. 498 */ 499 public void setLanguage(PgLanguage language) 500 { 501 pango_context_set_language(pangoContext, (language is null) ? null : language.getPgLanguageStruct()); 502 } 503 504 /** 505 * Sets the transformation matrix that will be applied when rendering 506 * with this context. 507 * 508 * Note that reported metrics are in the user space coordinates before 509 * the application of the matrix, not device-space coordinates after the 510 * application of the matrix. So, they don't scale with the matrix, though 511 * they may change slightly for different matrices, depending on how the 512 * text is fit to the pixel grid. 513 * 514 * Params: 515 * matrix = a `PangoMatrix`, or %NULL to unset any existing 516 * matrix. (No matrix set is the same as setting the identity matrix.) 517 * 518 * Since: 1.6 519 */ 520 public void setMatrix(PgMatrix matrix) 521 { 522 pango_context_set_matrix(pangoContext, (matrix is null) ? null : matrix.getPgMatrixStruct()); 523 } 524 525 /** 526 * Sets whether font rendering with this context should 527 * round glyph positions and widths to integral positions, 528 * in device units. 529 * 530 * This is useful when the renderer can't handle subpixel 531 * positioning of glyphs. 532 * 533 * The default value is to round glyph positions, to remain 534 * compatible with previous Pango behavior. 535 * 536 * Params: 537 * roundPositions = whether to round glyph positions 538 * 539 * Since: 1.44 540 */ 541 public void setRoundGlyphPositions(bool roundPositions) 542 { 543 pango_context_set_round_glyph_positions(pangoContext, roundPositions); 544 } 545 546 /** 547 * Determines the bidirectional type of a character. 548 * 549 * The bidirectional type is specified in the Unicode Character Database. 550 * 551 * A simplified version of this function is available as [func@unichar_direction]. 552 * 553 * Params: 554 * ch = a Unicode character 555 * 556 * Returns: the bidirectional character type, as used in the 557 * Unicode bidirectional algorithm. 558 * 559 * Since: 1.22 560 */ 561 public static PangoBidiType bidiTypeForUnichar(dchar ch) 562 { 563 return pango_bidi_type_for_unichar(ch); 564 } 565 566 /** 567 * Determines possible line, word, and character breaks 568 * for a string of Unicode text with a single analysis. 569 * 570 * For most purposes you may want to use [func@Pango.get_log_attrs]. 571 * 572 * Deprecated: Use [func@Pango.default_break], 573 * [func@Pango.tailor_break] and [func@Pango.attr_break]. 574 * 575 * Params: 576 * text = the text to process. Must be valid UTF-8 577 * length = length of @text in bytes (may be -1 if @text is nul-terminated) 578 * analysis = `PangoAnalysis` structure for @text 579 * attrs = an array to store character information in 580 */ 581 public static void pangoBreak(string text, int length, PangoAnalysis* analysis, PangoLogAttr[] attrs) 582 { 583 pango_break(Str.toStringz(text), length, analysis, attrs.ptr, cast(int)attrs.length); 584 } 585 586 /** 587 * This is the default break algorithm. 588 * 589 * It applies rules from the [Unicode Line Breaking Algorithm](http://www.unicode.org/unicode/reports/tr14/) 590 * without language-specific tailoring, therefore the @analyis argument is unused 591 * and can be %NULL. 592 * 593 * See [func@Pango.tailor_break] for language-specific breaks. 594 * 595 * See [func@Pango.attr_break] for attribute-based customization. 596 * 597 * Params: 598 * text = text to break. Must be valid UTF-8 599 * length = length of text in bytes (may be -1 if @text is nul-terminated) 600 * analysis = a `PangoAnalysis` structure for the @text 601 * attrs = logical attributes to fill in 602 * attrsLen = size of the array passed as @attrs 603 */ 604 public static void defaultBreak(string text, int length, PangoAnalysis* analysis, PangoLogAttr* attrs, int attrsLen) 605 { 606 pango_default_break(Str.toStringz(text), length, analysis, attrs, attrsLen); 607 } 608 609 /** 610 * Searches a string the first character that has a strong 611 * direction, according to the Unicode bidirectional algorithm. 612 * 613 * Params: 614 * text = the text to process. Must be valid UTF-8 615 * length = length of @text in bytes (may be -1 if @text is nul-terminated) 616 * 617 * Returns: The direction corresponding to the first strong character. 618 * If no such character is found, then %PANGO_DIRECTION_NEUTRAL is returned. 619 * 620 * Since: 1.4 621 */ 622 public static PangoDirection findBaseDir(string text, int length) 623 { 624 return pango_find_base_dir(Str.toStringz(text), length); 625 } 626 627 /** 628 * Locates a paragraph boundary in @text. 629 * 630 * A boundary is caused by delimiter characters, such as 631 * a newline, carriage return, carriage return-newline pair, 632 * or Unicode paragraph separator character. 633 * 634 * The index of the run of delimiters is returned in 635 * @paragraph_delimiter_index. The index of the start of the 636 * next paragraph (index after all delimiters) is stored n 637 * @next_paragraph_start. 638 * 639 * If no delimiters are found, both @paragraph_delimiter_index 640 * and @next_paragraph_start are filled with the length of @text 641 * (an index one off the end). 642 * 643 * Params: 644 * text = UTF-8 text 645 * length = length of @text in bytes, or -1 if nul-terminated 646 * paragraphDelimiterIndex = return location for index of 647 * delimiter 648 * nextParagraphStart = return location for start of next 649 * paragraph 650 */ 651 public static void findParagraphBoundary(string text, int length, out int paragraphDelimiterIndex, out int nextParagraphStart) 652 { 653 pango_find_paragraph_boundary(Str.toStringz(text), length, ¶graphDelimiterIndex, &nextParagraphStart); 654 } 655 656 /** 657 * Computes a `PangoLogAttr` for each character in @text. 658 * 659 * The @attrs array must have one `PangoLogAttr` for 660 * each position in @text; if @text contains N characters, 661 * it has N+1 positions, including the last position at the 662 * end of the text. @text should be an entire paragraph; 663 * logical attributes can't be computed without context 664 * (for example you need to see spaces on either side of 665 * a word to know the word is a word). 666 * 667 * Params: 668 * text = text to process. Must be valid UTF-8 669 * length = length in bytes of @text 670 * level = embedding level, or -1 if unknown 671 * language = language tag 672 * attrs = array with one `PangoLogAttr` 673 * per character in @text, plus one extra, to be filled in 674 */ 675 public static void getLogAttrs(string text, int length, int level, PgLanguage language, PangoLogAttr[] attrs) 676 { 677 pango_get_log_attrs(Str.toStringz(text), length, level, (language is null) ? null : language.getPgLanguageStruct(), attrs.ptr, cast(int)attrs.length); 678 } 679 680 /** 681 * Returns the mirrored character of a Unicode character. 682 * 683 * Mirror characters are determined by the Unicode mirrored property. 684 * 685 * Deprecated: Use [func@GLib.unichar_get_mirror_char] instead; 686 * the docs for that function provide full details. 687 * 688 * Params: 689 * ch = a Unicode character 690 * mirroredCh = location to store the mirrored character 691 * 692 * Returns: %TRUE if @ch has a mirrored character and @mirrored_ch is 693 * filled in, %FALSE otherwise 694 */ 695 public static bool getMirrorChar(dchar ch, dchar* mirroredCh) 696 { 697 return pango_get_mirror_char(ch, mirroredCh) != 0; 698 } 699 700 /** 701 * Breaks a piece of text into segments with consistent directional 702 * level and font. 703 * 704 * Each byte of @text will be contained in exactly one of the items in the 705 * returned list; the generated list of items will be in logical order (the 706 * start offsets of the items are ascending). 707 * 708 * @cached_iter should be an iterator over @attrs currently positioned 709 * at a range before or containing @start_index; @cached_iter will be 710 * advanced to the range covering the position just after 711 * @start_index + @length. (i.e. if itemizing in a loop, just keep passing 712 * in the same @cached_iter). 713 * 714 * Params: 715 * context = a structure holding information that affects 716 * the itemization process. 717 * text = the text to itemize. Must be valid UTF-8 718 * startIndex = first byte in @text to process 719 * length = the number of bytes (not characters) to process 720 * after @start_index. This must be >= 0. 721 * attrs = the set of attributes that apply to @text. 722 * cachedIter = Cached attribute iterator 723 * 724 * Returns: a `GList` of 725 * [struct@Pango.Item] structures. The items should be freed using 726 * [method@Pango.Item.free] in combination with [func@GLib.List.free_full]. 727 */ 728 public static ListG itemize(PgContext context, string text, int startIndex, int length, PgAttributeList attrs, PgAttributeIterator cachedIter) 729 { 730 auto __p = pango_itemize((context is null) ? null : context.getPgContextStruct(), Str.toStringz(text), startIndex, length, (attrs is null) ? null : attrs.getPgAttributeListStruct(), (cachedIter is null) ? null : cachedIter.getPgAttributeIteratorStruct()); 731 732 if(__p is null) 733 { 734 return null; 735 } 736 737 return new ListG(cast(GList*) __p, true); 738 } 739 740 /** 741 * Like `pango_itemize()`, but with an explicitly specified base direction. 742 * 743 * The base direction is used when computing bidirectional levels. 744 * [func@itemize] gets the base direction from the `PangoContext` 745 * (see [method@Pango.Context.set_base_dir]). 746 * 747 * Params: 748 * context = a structure holding information that affects 749 * the itemization process. 750 * baseDir = base direction to use for bidirectional processing 751 * text = the text to itemize. 752 * startIndex = first byte in @text to process 753 * length = the number of bytes (not characters) to process 754 * after @start_index. This must be >= 0. 755 * attrs = the set of attributes that apply to @text. 756 * cachedIter = Cached attribute iterator 757 * 758 * Returns: a `GList` of 759 * [struct@Pango.Item] structures. The items should be freed using 760 * [method@Pango.Item.free] probably in combination with [func@GLib.List.free_full]. 761 * 762 * Since: 1.4 763 */ 764 public static ListG itemizeWithBaseDir(PgContext context, PangoDirection baseDir, string text, int startIndex, int length, PgAttributeList attrs, PgAttributeIterator cachedIter) 765 { 766 auto __p = pango_itemize_with_base_dir((context is null) ? null : context.getPgContextStruct(), baseDir, Str.toStringz(text), startIndex, length, (attrs is null) ? null : attrs.getPgAttributeListStruct(), (cachedIter is null) ? null : cachedIter.getPgAttributeIteratorStruct()); 767 768 if(__p is null) 769 { 770 return null; 771 } 772 773 return new ListG(cast(GList*) __p, true); 774 } 775 776 /** 777 * Reorder items from logical order to visual order. 778 * 779 * The visual order is determined from the associated directional 780 * levels of the items. The original list is unmodified. 781 * 782 * (Please open a bug if you use this function. 783 * It is not a particularly convenient interface, and the code 784 * is duplicated elsewhere in Pango for that reason.) 785 * 786 * Params: 787 * items = a `GList` of `PangoItem` 788 * in logical order. 789 * 790 * Returns: a `GList` 791 * of `PangoItem` structures in visual order. 792 */ 793 public static ListG reorderItems(ListG items) 794 { 795 auto __p = pango_reorder_items((items is null) ? null : items.getListGStruct()); 796 797 if(__p is null) 798 { 799 return null; 800 } 801 802 return new ListG(cast(GList*) __p, true); 803 } 804 805 /** 806 * Convert the characters in @text into glyphs. 807 * 808 * Given a segment of text and the corresponding `PangoAnalysis` structure 809 * returned from [func@Pango.itemize], convert the characters into glyphs. You 810 * may also pass in only a substring of the item from [func@Pango.itemize]. 811 * 812 * It is recommended that you use [func@Pango.shape_full] instead, since 813 * that API allows for shaping interaction happening across text item 814 * boundaries. 815 * 816 * Note that the extra attributes in the @analyis that is returned from 817 * [func@Pango.itemize] have indices that are relative to the entire paragraph, 818 * so you need to subtract the item offset from their indices before 819 * calling [func@Pango.shape]. 820 * 821 * Params: 822 * text = the text to process 823 * length = the length (in bytes) of @text 824 * analysis = `PangoAnalysis` structure from [func@Pango.itemize] 825 * glyphs = glyph string in which to store results 826 */ 827 public static void shape(string text, int length, PangoAnalysis* analysis, PgGlyphString glyphs) 828 { 829 pango_shape(Str.toStringz(text), length, analysis, (glyphs is null) ? null : glyphs.getPgGlyphStringStruct()); 830 } 831 832 /** 833 * Convert the characters in @text into glyphs. 834 * 835 * Given a segment of text and the corresponding `PangoAnalysis` structure 836 * returned from [func@Pango.itemize], convert the characters into glyphs. 837 * You may also pass in only a substring of the item from [func@Pango.itemize]. 838 * 839 * This is similar to [func@Pango.shape], except it also can optionally take 840 * the full paragraph text as input, which will then be used to perform 841 * certain cross-item shaping interactions. If you have access to the broader 842 * text of which @item_text is part of, provide the broader text as 843 * @paragraph_text. If @paragraph_text is %NULL, item text is used instead. 844 * 845 * Note that the extra attributes in the @analyis that is returned from 846 * [func@Pango.itemize] have indices that are relative to the entire paragraph, 847 * so you do not pass the full paragraph text as @paragraph_text, you need 848 * to subtract the item offset from their indices before calling 849 * [func@Pango.shape_full]. 850 * 851 * Params: 852 * itemText = valid UTF-8 text to shape. 853 * itemLength = the length (in bytes) of @item_text. -1 means nul-terminated text. 854 * paragraphText = text of the paragraph (see details). 855 * paragraphLength = the length (in bytes) of @paragraph_text. -1 means nul-terminated text. 856 * analysis = `PangoAnalysis` structure from [func@Pango.itemize]. 857 * glyphs = glyph string in which to store results. 858 * 859 * Since: 1.32 860 */ 861 public static void shapeFull(string itemText, int itemLength, string paragraphText, int paragraphLength, PangoAnalysis* analysis, PgGlyphString glyphs) 862 { 863 pango_shape_full(Str.toStringz(itemText), itemLength, Str.toStringz(paragraphText), paragraphLength, analysis, (glyphs is null) ? null : glyphs.getPgGlyphStringStruct()); 864 } 865 866 /** 867 * Determines the inherent direction of a character. 868 * 869 * The inherent direction is either `PANGO_DIRECTION_LTR`, `PANGO_DIRECTION_RTL`, 870 * or `PANGO_DIRECTION_NEUTRAL`. 871 * 872 * This function is useful to categorize characters into left-to-right 873 * letters, right-to-left letters, and everything else. If full Unicode 874 * bidirectional type of a character is needed, [func@Pango.BidiType.for_unichar] 875 * can be used instead. 876 * 877 * Params: 878 * ch = a Unicode character 879 * 880 * Returns: the direction of the character. 881 */ 882 public static PangoDirection unicharDirection(dchar ch) 883 { 884 return pango_unichar_direction(ch); 885 } 886 }